package com.systemdevelopment.mainproject.View.Visitor;

import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXPasswordField;
import com.jfoenix.controls.JFXTextField;
import com.systemdevelopment.mainproject.View.mainUI;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.input.InputMethodEvent;

public class RegisterPaneController {

        @FXML
        private JFXTextField userNameField;
        @FXML
        private JFXPasswordField PassField;
        @FXML
        private JFXButton registerButton;
        @FXML
        private Label loginTitle;
        @FXML
        private JFXPasswordField PassRepeatField;
        @FXML
        void PasswordCheck(InputMethodEvent event) {
            if(isPasswordAvailable())
            {
                System.out.println("密码可用");
            }
            else
            {
                System.out.println("密码不一致");
            }
        }
        boolean isPasswordAvailable()
        {
            return !PassField.getText().isEmpty()&&PassField.getText().equals(PassRepeatField.getText());

        }
        @FXML
        void Register(ActionEvent event) {
            if(isPasswordAvailable()&&
                    mainUI.getVisitorController().register(userNameField.getText(),PassField.getText()))
            {
                System.out.println("注册成功");
            }
            else
                System.out.println("注册失败");


        }

    }
